﻿// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using NSQL.Expressions;
using NSQL.Statements;

namespace NSQL.Extensions
{
    public static class ValueExpressionExtensions
    {
        public static NullExpression IsNull(this IExpression expression)
        {
            return new NullExpression(expression);
        }
        public static NotNullExpression IsNotNull(this IExpression expression)
        {
            return new NotNullExpression(expression);
        }

        public static ComparisonExpression Equal(this IExpression expression, ConstantExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.Equal);
        }
        
        public static ComparisonExpression Equal(this IExpression expression, IExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.Equal);
        }
        public static ComparisonExpression Less(this IExpression expression, ConstantExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.Less);
        }
        public static ComparisonExpression Less(this IExpression expression, IExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.Less);
        }
        public static ComparisonExpression Greater(this IExpression expression, ConstantExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.Greater);
        }
        public static ComparisonExpression Greater(this IExpression expression, IExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.Greater);
        }
        public static ComparisonExpression LessOrEqual(this IExpression expression, ConstantExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.LessOrEqual);
        }
        public static ComparisonExpression LessOrEqual(this IExpression expression, IExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.LessOrEqual);
        }
        
        public static ComparisonExpression GreaterOrEqual(this IExpression expression, ConstantExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.GreaterOrEqual);
        }
        public static ComparisonExpression GreaterOrEqual(this IExpression expression, IExpression other)
        {
            return new ComparisonExpression(expression, other, ComparisonOperator.GreaterOrEqual);
        }

        public static SelectElement As(this IExpression expression, Identifier alias)
        {
            return new SelectElement(expression, alias);
        }
    }
}